package com.example.fragmentnews;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class NewsContentFragment extends Fragment {

    private View view;

    @Nullable
    @Override
    //拿到 news_content_frag 布局    双
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       //加载布局
        view  = inflater.inflate(R.layout.news_content_frag, container, false);
        return  view;
    }

    //刷新
    public void refresh(String newsTitle,String newsContent){
        View visibilityLayout = view.findViewById(R.id.visisbility_layout);
        visibilityLayout.setVisibility(View.VISIBLE);   //设置可见的
        //拿到id
        TextView newsTitleText = (TextView) view.findViewById(R.id.news_title);
        TextView newsContenText = (TextView) view.findViewById(R.id.news_content);
        newsTitleText.setText(newsTitle);    //刷新新闻的标题
        newsContenText.setText(newsContent); //刷新新闻的内容



    }
}
